package com.bw.controller;

import com.bw.entity.Power;
import com.bw.entity.User;
import com.bw.service.ZtreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/ztree")
public class ZtreeController {

    @Autowired
    private ZtreeService ztreeService;

    @RequestMapping("/list")
    @ResponseBody
    public List<Power> list(HttpSession session){

        User user = (User) session.getAttribute("user");
        Map map = new HashMap<String,Object>();
        map.put("id",user.getId());
        List<Power> plist = ztreeService.findPoweList(map);

        return plist;
    }
}
